//
//  CZMainViewController.swift
//  weibo008
//
//  Created by 大米 on 16/2/27.
//  Copyright © 2016年 大米. All rights reserved.
//

import UIKit

class CZMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
//        tabBar.tintColor = UIColor.orangeColor()
        
       
        setValue(CZMainTabber(), forKey: "tabBar")
        
        addChildViewControllers()
    }

    func addChildViewControllers() {
        //首页
        let homeVC = CZHomeViewController()
        addChildViewController(homeVC, title: "首页", imageName: "tabbar_home")
        
        //消息
        let messageVC = CZHomeViewController()
        addChildViewController(messageVC, title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(UIViewController())
        
        
        //发现
        let discoverVC = CZHomeViewController()
        addChildViewController(discoverVC, title: "发现", imageName: "tabbar_discover")
        
        //我
        let profileVC = CZHomeViewController()
        addChildViewController(profileVC, title: "我", imageName: "tabbar_profile")
    }
    
   
    
    
    
    func addChildViewController(controller: UIViewController, title:String, imageName: String) {
        //设置title
        controller.title = title
        controller.tabBarItem.image = UIImage(named: imageName)
        //设置选中图片
        let hightedimage = imageName + "_highlighted"
        //设置图片不要渲染
        controller.tabBarItem.selectedImage = UIImage(named: hightedimage)?.imageWithRenderingMode(.AlwaysOriginal)
        //设置选中文字的颜色
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: UIControlState.Selected)
        
        
        addChildViewController( UINavigationController(rootViewController: controller))
    }

}
